USE [i8office]
GO

if (exists (select * from sys.objects where name = 'proc_wkf_message'))
	drop proc proc_wkf_message
go
create proc proc_wkf_message(
	@MessageID varchar(36),
	@MessageIssuedBy nvarchar(20),
	@MessageIssuedDept nvarchar(36),
	@FromTemplate varchar(36)
)
as
	INSERT INTO [dbo].[WKF_Message]
           ([MessageID]
           ,[MessageTitle]
           ,[MessageCreateTime]
           ,[MessageFinishTime]
           ,[MessageTimeLimit]
           ,[MessageFinishTimeExpected]
           ,[MessageIssuedBy]
           ,[MessageIssuedByAgent]
           ,[MessageIssuedDept]
           ,[MessageNote]
           ,[InitNodeKey]
           ,[MessageStatus]
           ,[IsTemplate]
           ,[MessageType]
           ,[MessageTypeKey]
           ,[MessageHelper]
           ,[FromTemplate]
           ,[DataSourceID])
     SELECT
           @MessageID
           ,[MessageTitle]
           ,GETDATE()
           ,GETDATE()
           ,[MessageTimeLimit]
           ,[MessageFinishTimeExpected]
           ,@MessageIssuedBy
           ,[MessageIssuedByAgent]
           ,@MessageIssuedDept
           ,[MessageNote]
           ,[InitNodeKey]
           ,1
           ,0
           ,[MessageType]
           ,[MessageTypeKey]
           ,[MessageHelper]
           ,@FromTemplate
           ,[DataSourceID]
	FROM [dbo].[WKF_Message]
	WHERE MessageID = @FromTemplate
go


